﻿using B.Auth.APi.Application.Command.Role;
using B.Auth.Domain.Entity;
using B.Auth.Domain.Repository;
using B.Auth.Enum;
using MediatR;

namespace B.Auth.APi.Application.CommandHand.Role
{
    public class DelRoleCommandHand : IRequestHandler<DelRoleCommand, ApiResult<int>>
    {
        private readonly IBaseRepository<RoleModel> db;

        public DelRoleCommandHand(IBaseRepository<RoleModel> db)
        {
            this.db = db;
        }

        public Task<ApiResult<int>> Handle(DelRoleCommand request, CancellationToken cancellationToken)
        {
            var result = new ApiResult<int>();
            var user = new RoleModel();
            user.Id = request.Id;
            user.RoleName = request.RoleName;
           
            user.Del = 1;
            user.CreateUserName = "张三";
            user.CreateTime = DateTime.Now;
            user.UpdateTime = DateTime.Now;
            user.UodateUserName = "张三";
           db.Update(user);
           
            result.Message = "成功";
            return Task.FromResult(result);
        }
    }
}
